package com.cx.file.exception;


import com.cx.file.model.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author cx
 * @description: 统一异常处理
 * @date 2023/5/8 17:15
 */
@RestControllerAdvice
public class ExceptionHandling {

    private static final Logger logger = LoggerFactory.getLogger(ExceptionHandling.class);


    @ExceptionHandler(value = FileManageException.class)
    @ResponseStatus(HttpStatus.OK)
    public Result<Object> handlerFileManageException(FileManageException ex) {
        String msg = ex.getMessage();
        logger.error(msg);
        return Result.error(msg);
    }
}
